package com.lemo.controller;

import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RandomNumController {
		
	@Autowired
	private DiscoveryClient client;
	
	
	@GetMapping("randomNum")
	public int randomNum(){
		ServiceInstance localServiceInstance = client.getLocalServiceInstance();
		System.err.println("host:"+localServiceInstance.getHost());
		Random random = new Random();
		return random.nextInt();
	}
}
